//
//  MM_MacrosFile_h.h
//  MallManage_IOS
//
//  Created by 张浩 on 2023/9/11.
//

#ifndef MM_MacrosFile_h_h
#define MM_MacrosFile_h_h

#pragma mark ----------------    布局      ------------------
/** 屏幕宽高
 
 @param 宽高
 */
#define ScreenW   [UIScreen mainScreen].bounds.size.width

#define ScreenH   [UIScreen mainScreen].bounds.size.height

/**
 导航栏高度
 
 @param 64.f iPhoneX 之前
 @return 导航栏高度
 */
#define NaviBarHeight (is_iPhoneX ? 88.f : 64.f)

/**
 tabBar高度
 
 @param 49.f+34.f iPhoneX
 @return tabBar高度
 */
#define TabBarHeight (is_iPhoneX ? (49.f+34.f) : 49.f)

/**
 顶部电池条高度
 */
#define TopStatusViewHeight (is_iPhoneX ? 44.f : 20.f)
/**
 底部bottom
 
 @param 0.f iPhoneX 之前
 @return 底部高度
 */

#define HomeIndicatorHeight (is_iPhoneX ? 34.f : 0.f)

/**
 判断是否是iPhone X
 
 @param currentMode
 @return YES 是 否则不是
 */

//#define is_iPhoneX ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1125, 2436), [[UIScreen mainScreen] currentMode].size) : NO)
#define is_iPhoneX \
({BOOL isPhoneX = NO;\
if (@available(iOS 11.0, *)) {\
isPhoneX = [[UIApplication sharedApplication] delegate].window.safeAreaInsets.bottom > 0.0;\
}\
(isPhoneX);})

//按比例计算尺寸 设计稿是以750为基准  //  (size)*ScreenW/750
#define RATIO(size)      (size)/2.0
//等比适配
#define Equal_Ratio(size)   (size)*ScreenW/750
// 等比适配
#define ScreenMatch(size)  RATIO(size)

//等比宽度
#define Scale_W(size)       (size)*ScreenW/750
//等比高度
#define Scale_H(size)       (size)*ScreenH/1336

//间距
#define MARGIN_SMALL            RATIO(16)
#define MARGIN                  RATIO(24)
#define MARGIN_BIG              RATIO(32)

//微店顶部图片高度
#define Height_AngelStoreImg   ScreenW*7.0/16

/* 一个像素的高 **/
#define MM_SINGLE_LINE_Height           (1.0 / [UIScreen mainScreen].scale)
/* 一个像素的宽 **/
#define MM_SINGLE_LINE_Width           (1.0 / [UIScreen mainScreen].scale)

#define MM_Image(str)    [UIImage imageNamed:str]

#define MM_ColorUtil(str)    [ColorUtil colorWithHexadecimal:str]

#pragma mark ----------------    其他      ------------------

/**
 blook
 
 @param weakSelf
 */
#define WS(weakSelf)  __weak __typeof(&*self)weakSelf = self;

/// 第一个参数是当下的控制器适配iOS11 一下的，第二个参数表示scrollview或子类
#define AdjustsScrollViewInsetNever(controller,view) if(@available(iOS 11.0, *)) {view.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;} else if([controller isKindOfClass:[UIViewController class]]) {controller.automaticallyAdjustsScrollViewInsets = false;}

//字体
#define FONT(s)               [UIFont systemFontOfSize:(s)]
#define FONT_BOLD(s)          [UIFont boldSystemFontOfSize:(s)]

//全局字体
#define Font_BtnTitle           FONT(RATIO(28))

/* 表示已经减半的字体**/
#define MM_Ture_Font(VALUE)     FONT(RATIO(VALUE))
#define GTT_Font(VALUE)         MM_Ture_Font(VALUE)

#define BOTTOMH     RATIO(98)


//判断空字符串
#define MM_Str(str) [str stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]
#define stringIsEmpty(str) ([str isKindOfClass:[NSNull class]] || !str || [MM_Str(str) isEqualToString:@""] || [str isEqualToString:@"<null>"])

//系统单利
#define UserDefaults           [NSUserDefaults standardUserDefaults]
#define MMNotificationCenter   [NSNotificationCenter defaultCenter]

#ifdef DEBUG
#define MMLog(FORMAT,...)     fprintf(stderr, "LOG %s:%d行=>%s\n",__PRETTY_FUNCTION__,__LINE__,[[NSString stringWithFormat:FORMAT,##__VA_ARGS__]UTF8String])
#define NSLog(FORMAT,...)     fprintf(stderr, "LOG %s:%d行=>%s\n",__PRETTY_FUNCTION__,__LINE__,[[NSString stringWithFormat:FORMAT,##__VA_ARGS__]UTF8String])

#else
#define MMLog(...) do{}while(0)
#define NSLog(FORMAT,...) do{}while(0)
#endif

#define MMLogFunc MMLog(@"%s", __func__)


//判断空字符串
#define MM_Str(str) [str stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]
#define stringIsEmpty(str) ([str isKindOfClass:[NSNull class]] || !str || [MM_Str(str) isEqualToString:@""] || [str isEqualToString:@"<null>"])

#pragma mark ----------------    颜色      ------------------
/**
 三原色设置颜色
 
 @param 颜色
 */
#define RGBA(r,g,b,a)     [UIColor colorWithRed:(r)/255.0f green:(g)/255.0f blue:(b)/255.0f alpha:a]
#define RGB(r,g,b)        RGBA(r,g,b,1)

#endif /* MM_MacrosFile_h_h */
